const { list } = require('./mock')

module.exports = (app) => {
  app.get('/api/list', (req, res) => {
    res.send({
      code: 200,
      list,
    })
  })

  app.get('/api/list/:id', (req, res) => {
    const { id } = req.params
    const item = list.find((v) => v.id === id)
    if (item) {
      res.send({
        code: 200,
        data: item,
        messgae: 'ok',
      })
    } else {
      res.send({
        code: 400,
      })
    }
  })
}
